#include "dominion.h"
#include "dominion_helpers.h"
#include <string.h>
#include <stdio.h>
#include <assert.h>
#include "rngs.h"

int checkUpdateCoins(int p, struct gameState *state, int coinCount) {

	int r, i;
	i = 0;

	r = updateCoins(p, state, i);
	assert(r == 0);
	assert(state->coins == coinCount);
	printf("initial tests passed!\n");	

	for (i = 0; i < 3; i++) {
		r = updateCoins(p, state, i);
		assert(r == 0);
		assert(state->coins == coinCount + i);
		printf("bonus tests passed!\n");
	}
}

int main() {

	int r, p, i, j, coinCount;
	int k[10] = {adventurer, council_room, feast, gardens, mine, remodel, smithy, village, baron, great_hall};

	struct gameState G;

	for (p = 0; p < 2; p++) {
		for (i = 0; i < 20; i++) {
			memset(&G, 23, sizeof(struct gameState));
			r = initializeGame(2, k, 1, &G);
			G.handCount[p] = i;
			memset(G.hand[p], 0, sizeof(int) * i);
			coinCount = 0;
			for (j = 0; j < i; j++) {
				if (i % 3 == 0) {
					G.hand[p][j] = copper;
					coinCount += 1;
				}
				else if (i % 3 == 1) {
					G.hand[p][j] = silver;
					coinCount += 2;
				}
				else {
					G.hand[p][j] = gold;
					coinCount += 3;
				}
			}
			checkUpdateCoins(p, &G, coinCount);
		}
	}
}
